package com.hc.model.code04.test;

import com.hc.model.code04.test.impl.ZhangSanHandler;

import java.util.HashMap;
import java.util.Map;

/**
 * @version v1.0
 * @ClassName: Factory
 * @Description: 工厂模式
 * @Author: HC
 */
public class Factory {

    private static Map<String, Handler> strategyMap = new HashMap<>();

    static {
        new ZhangSanHandler().afterPropertiesSet();

    }

    public static Handler getInvokeStrategy(String str) {
       return strategyMap.get(str);
    }

    public static void register(String name, Handler handler) {
        if ("".equals(name) || null == handler) {
            return;
        }
        strategyMap.put(name, handler);
    }


}
